<?php
/**
* @file $Id: DeletePrompt.fnc.php 161 2006-09-07 06:21:17Z doritojones $
* @package Focus/SIS
* @copyright Copyright (C) 2006 Andrew Schmadeke. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.txt
* Focus/SIS is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.txt for copyright notices and details.
*/

// example:
//
//	if(DeletePrompt('Title'))
//	{
//		DBQuery("DELETE FROM BOK WHERE id='$_REQUEST[benchmark_id]'");
//	}


function DeletePrompt($title,$action='delete')
{
	if($action=='Delete')
		$action = _('Delete');

	$tmp_REQUEST = $_REQUEST;
	unset($tmp_REQUEST['delete_ok']);
		
	$PHP_tmp_SELF = PreparePHP_SELF($tmp_REQUEST);

	if(!$_REQUEST['delete_ok'] && !$_REQUEST['delete_cancel'])
	{
		echo '<BR>';
		PopTable('header',_('Confirm').(strpos($action,' ')===false?' '.ucwords($action):''));
		echo "<CENTER><h4>"._('Are you sure you want to')." $action "._('that')." $title?</h4><FORM action=$PHP_tmp_SELF&delete_ok=1 METHOD=POST><INPUT type=submit value="._('OK')."><INPUT type=button name=delete_cancel value="._('Cancel')." onclick='javascript:history.go(-1);'></FORM></CENTER>";
		PopTable('footer');
		return false;
	}
	else
		return true;
}

function Prompt($title='Confirm',$question='',$message='',$pdf='')
{	
	if($title=='Confirm')
		$title = _('Confirm');
	$tmp_REQUEST = $_REQUEST;
	unset($tmp_REQUEST['delete_ok']);
	if($pdf==true)
		$tmp_REQUEST['_FOCUS_PDF'] = true;
		
	$PHP_tmp_SELF = PreparePHP_SELF($tmp_REQUEST);

	if(!$_REQUEST['delete_ok'] &&!$_REQUEST['delete_cancel'])
	{
		echo '<BR>';
		PopTable('header',$title);
		echo "<CENTER><h4>$question</h4><FORM action=$PHP_tmp_SELF&delete_ok=1 METHOD=POST>$message<BR><BR><INPUT type=submit value="._('OK')."><INPUT type=button name=delete_cancel value="._('Cancel')." onclick='javascript:history.go(-1);'></FORM></CENTER>";
		PopTable('footer');
		return false;
	}
	else
		return true;	
}

?>